package com.whc.tag;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.BodyTagSupport;

import com.system.comm.util.SpringContextUtil;
import com.system.common.mapper.BisShopUserMapper;
import com.system.common.pojo.BisShopUser;

public class ShopUserName extends BodyTagSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String serverUserId;
	

	public String getServerUserId() {
		return serverUserId;
	}

	public void setServerUserId(String serverUserId) {
		this.serverUserId = serverUserId;
	}

	@Override
	public int doStartTag() throws JspException { // 在标签开始处出发该方法
		 JspWriter writer = this.pageContext.getOut();
		 BisShopUserMapper BisShopUserMapper=(BisShopUserMapper) SpringContextUtil.getBean("bisShopUserMapper");		 
		try {
			BisShopUser bisShopUser = BisShopUserMapper.selectByPrimaryKey(serverUserId);			
			if(bisShopUser!=null){
				writer.write(bisShopUser.getUsername());				
			}else{
				writer.write("数据有误");
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		return BodyTagSupport.SKIP_BODY;
	}

	@Override
	public int doEndTag() throws JspException {
		return BodyTagSupport.EVAL_BODY_INCLUDE;
	}
	
}
